<?php
require ("../lib/phpmailer/class.phpmailer.php");

class Mailer {

	private $to;
	private $from = "Mailer";
	private $from_address = "mailer@domain.com";
	private $host = "mail.domain.com";
	private $username = "mailer@domain.com";
	private $password = "password";
	private $subject;
	private $body;
	private $mail;
	private $port = 26;
	
	function Mailer() {
		$this->mail = new PHPMailer();
		$this->mail->IsSMTP(); // set mailer to use SMTP
		$this->mail->Host = $this->host;
		$this->mail->SMTPAuth = true;     // turn on SMTP authentication
		$this->mail->Username = $this->username;  // SMTP username
		$this->mail->Password = $this->password; // SMTP password		
		$this->mail->From = $this->from_address;
		$this->mail->FromName = $this->from;
		$this->mail->Port = $this->port;
	}

	function support_mail($subj, $msg) {
		$this->fast_mail("support@domain.com", "Domain-Support: ".$subj, $msg);
	}

	function html_mail($to, $subj, $msg) {
		$message = new Mail_mime();
		$headers = array (
			'From' => $this->from,
			'To' => $to,
			'Subject' => 'DO NOT REPLY: ' . $subj,
			'Content-Type' => 'text/html; charset=ISO-8859-1',
			'MIME-Version' => '1.0'
		);
		$message->setTXTBody('none');
		$message->setHTMLBody($msg);

		$body = $message->get();
		$this->mail = Mail :: factory('mail'
		, array (
			'host' => $this->host,
			'port' => 26,
			'auth' => true,
			'username' => $this->username,
			'password' => $this->password
		));
		$this->mail->send($to,$headers,$body);

	}

	function fast_mail($to, $subj, $msg) {
		$this->mail->AddAddress($to); 
		$this->mail->Subject = $subj;
		$this->mail->Body    = $msg;
		$this->mail->send();
	}
}

// unit test
$mailer = new Mailer();
$mailer->fast_mail('scott@domain.com','test','test body');
$mailer->html_mail('scott@domain.com', 'test', '<h1>this is a test</h1>');
?>